<?php
/**
 * Hoa Framework
 *
 *
 * @license
 *
 * GNU General Public License
 *
 * This file is part of HOA Open Accessibility.
 * Copyright (c) 2007, 2008 Ivan ENDERLIN. All rights reserved.
 *
 * HOA Open Accessibility is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * HOA Open Accessibility is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with HOA Open Accessibility; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 *
 *
 * @category    Framework
 * @package     Hoa_Framework
 *
 */

/**
 * Hoa_Framework
 */
require_once 'Framework.php';

/**
 * Hoathis_Twitter_Decorator_Abstract
 */
importModule('Twitter.Decorator.Abstract');

/**
 * Class Hoathis_Twitter_Decorator_List
 *
 * @author      Gregory DARCHE <tetardo@gmail.com>
 * @copyright   Copyright (c) 2009 Life In The Cloud. http://lifeinthecloud.fr
 * @license     http://gnu.org/licenses/gpl.txt GNU GPL
 * @since       PHP 5
 * @version     0.1
 * @package     Hoathis_Twitter
 * @subpackage  Hoathis_Twitter_Decorator
 */
class Hoathis_Twitter_Decorator_List extends Hoathis_Twitter_Decorator_Abstract {

    /**
     * Replace Tweet Regex
     *
     * @var Array
     */
    protected $replace = array(

        // http, https, ftp
        '<a class="link" title="Twitter http link" href="$0">$0</a>',
        '<a class="link" title="Twitter https link" href="$0">$0</a>',
        '<a class="link" title="Twitter ftp link" href="$0">$0</a>',

        // @, #
        '@<a class="user" title="Twitter $1" href="http://twitter.com/$1">$1</a>',
        '#<a class="referer" title="Twitter $1" href="http://search.twitter.com/search?q=%23$1">$1</a>',

        // RT
        '<span class="rt" title="Tweet, tweet, tweet...">$1</span>'
    );

    /**
     * Make render
     *
     * @access  protected
     * @param   Array   $data   Tweet.
     * @return  String
     */
    protected function render( $data = array() ){

        return '
        <li class="twitter-tweet">
            '.$data->text_html.'<br />
            <span class="date">
                '.$data->created_at_formated.' -
                '.$data->source.' -
                <a class="retweet" href="'.$data->retweet_url.'" title="Tweet, tweet, tweet..." target="_blank">Retweet</a>
            </span>
        </li>';
    }
}
